// Covid-19 Vaccine Spillover onto General Vaccine Attitudes
/// Analysis of returning respondents between Waves 14 and 22
/// use "overtimeVAXHES-w14and22 - with insttrust.dta"
/// Table 2 and S19


////////////////////////////// DATA CLEANING - data already has these variables - code kept to show coding process 
//gen  pid7x = . if party7x == 0
//replace pid7x = (-party7x + 7)/6

//gen pid7y = party7y
//gen party7oldy = party7y
//replace pid7y = . if party7oldy == 0
//replace pid7y = (-party7oldy + 7)/6

//replace vaxhesx = vaxhesx/12
//replace vaxhesy = vaxhesy/12
//replace eduy = (eduy-1)/6
//replace edux = (edux-1)/6
//replace cov_vacx = (cov_vacx-1)/4
//replace cov_vacy = (cov_vacy-1)/4

//gen femalex = .
//replace femalex = 1 if genderx == 112
//replace femalex = 0 if genderx == 111

//gen blackx = 0 if racex != 112
//replace blackx = 1 if racex == 111
//gen hispx = 0 if racex != 113
//replace hispx = 1 if racex == 113
//gen whitex = 0 if racex != 111
//replace whitex = 1 if racex == 111

//gen incx = (incomex-1)/9
//gen ideox = (ideologyx-1)/6

//gen vaxheschange = vaxhesy-vaxhesx
//gen pidchange = pid7y-pid7x
//gen cov_vacchange = cov_vacy-cov_vacx 

//gen cov_vacx_3 = .
//replace cov_vacx_3 = 0 if cov_vacx < .5
//replace cov_vacx_3 = 2 if cov_vacx > .5
//replace cov_vacx_3 = 1 if cov_vacx == .5


		
////////////// ANALYSES ////////////////////////////////////////////
// Table 2
reg vaxheschange pid7x cov_vacx [pweight=weightnatx]
est store a0xa
reg vaxheschange i.femalex i.blackx i.hispx agex pid7x edux cov_vacx incx ideox [pweight=weightnatx]
est store a1xa
reg vaxheschange i.femalex i.blackx i.hispx agex c.pid7x##c.cov_vacx edux incx ideox [pweight=weightnatx]
est store a1xia

reg vaxheschange i.femalex i.blackx i.hispx agex i.pid33x##c.cov_vacx edux incx ideox [pweight=weightnatx]
est store a1_intx
reg pidchange vaxhesx i.femalex i.blackx i.hispx agex edux cov_vacx incx ideox [pweight=weightnatx]
est store a2xa
reg cov_vacchange vaxhesx i.femalex i.blackx i.hispx agex pid7x edux incx ideox [pweight=weightnatx]
est store a3xa

reg vaxheschange i.femalex i.blackx i.whitex agex pid7x edux cov_vacx incx ideox
est store b1x
reg pidchange vaxhesx i.femalex i.blackx i.whitex agex edux cov_vacx incx ideox
est store b2x
reg cov_vacchange vaxhesx i.femalex i.blackx i.whitex agex pid7x edux incx ideox
est store b3x

esttab a0xa a1xa a1xia a2xa a3xa using spilltable2.rtf, ///
        cells(b (star fmt(2) vacant("-")) se(par(( )))) ///
        starlevels(* 0.05 ** 0.01 *** 0.001) stats(N)
		
	

	
	
/// Table S1

logit flushotgoty flushotgotx pid7x covcon [pweight=weightnatx], or cluster(psid)
est store a0x
logit flushotgoty flushotgotx pid7x i.femalex i.blackx i.hispx agex eduy covcon incx [pweight=weightnatx], or cluster(psid)
est store a1x
logit flushotgoty flushotgotx c.pid7x##c.covcon i.femalex i.blackx i.hispx agex eduy incx [pweight=weightnatx], or cluster(psid)
est store a1xi
reg pidchange flushotgotx i.femalex i.blackx i.hispx agex eduy incx [pweight=weightnatx],  cluster(psid)
est store a2x
reg covcon flushotgotx pid7x i.femalex i.blackx i.hispx agex eduy incx [pweight=weightnatx],  cluster(psid)
est store a3x

esttab a0x a1x a1xi a2x a3x using spilltableS1.rtf, eform ///
        cells(b (star fmt(2) vacant("-")) se(par(( )))) ///
        starlevels(* 0.05 ** 0.01 *** 0.001) stats(N)
			
	
	
	
	
//// Table S19

	reg vaxheschange insttrustx cov_vacx [pweight=weightnatx]
	est store inst1
	reg vaxheschange pid7x insttrustx cov_vacx [pweight=weightnatx]
	est store inst2
	reg vaxheschange pid7x c.insttrustx##c.cov_vacx [pweight=weightnatx]
	est store inst3
	reg trustchange cov_vacx vaxhesx i.femalex i.blackx i.whitex agex pid7x edux incx ideox [pweight=weightnatx]
	est store inst4
//// appendix
esttab inst1 inst2 inst3 inst4 using spilltableS19.rtf, ///
        cells(b (star fmt(2) vacant("-")) se(par(( )))) ///
        starlevels(* 0.05 ** 0.01 *** 0.001) stats(N)
		


















